package com.sky.service.impl;

import com.sky.mapper.DishMapper;
import com.sky.mapper.SetmealMapper;
import com.sky.service.WorkspaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Slf4j
public class WorkspaceServiceImpl implements WorkspaceService {
    @Autowired
    private DishMapper dishMapper;
    @Autowired
    private SetmealMapper setmealMapper;

    @Override
    @Transactional
    public DishOverViewVO overviewDishes() {
        DishOverViewVO dish = new DishOverViewVO();
        //统计已停售菜品数量
        dish.setDiscontinued(dishMapper.getCount(0));
        //统计已起售菜品数量
        dish.setSold(dishMapper.getCount(1));
        log.info("得到的dish:{}",dish);
        return dish;
    }

    @Override
    public SetmealOverViewVO overviewSetmeals() {
        SetmealOverViewVO setmeal=new SetmealOverViewVO();
        setmeal.setDiscontinued(setmealMapper.getCount(0));
        setmeal.setSold(setmealMapper.getCount(1));
        return setmeal;
    }

    @Override
    public BusinessDataVO businessData() {
        BusinessDataVO businessDataVO = new BusinessDataVO();
//        TODO:查询今日运营数据，数据库查询
//        businessDataVO.setNewUsers();
//        businessDataVO.setOrderCompletionRate();
//        businessDataVO.setTurnover();
//        businessDataVO.setUnitPrice();
//        businessDataVO.setValidOrderCount();
        return businessDataVO;
    }
}
